$(document).ready(function () {  
    // $('.innerTab').scrollLeft(370);
    // 点击报名
    // $('.register').click(function(){
    //     var speed=300;//滑动的速度
    //     $('body,html').animate({ scrollTop: 3000 }, speed);
    // });
    var swiper = new Swiper('.beautiful .swiper-container', {
        // loop: true,
        navigation: {
            nextEl: '.swiper-button-next',
            prevEl: '.swiper-button-prev',
        },
        // 如果需要分页器
        pagination: {
            el: '.swiper-pagination',
            clickable: true,
        },
        initialSlide: 0, //初始化为第一张图
        observer: true, //修改swiper自己或子元素时，自动初始化swiper
        observeParents: true,
    });
    //tab 切换
    $('.tab li').click(function(){
        var idx = $(this).index();
        console.log(idx);
        $('.tab li').eq(idx).addClass('active').siblings('li').removeClass('active');
        // 换主图
        $('.mainImg img').attr('src','images/mainImg'+ idx +'.jpg');
        // 换轮播
        var _html = '';
        if(idx==3){
            for(i = 0;i < 4; i++) {
                _html += '<div class="swiper-slide">'+
                            '<img src="images/img'+ idx + '-'+ i +'.jpg" />'+
                         '</div>'
            }
        }else{
            for(i = 0;i < 5; i++) {
                _html += '<div class="swiper-slide">'+
                            '<img src="images/img'+ idx + '-'+ i +'.jpg" />'+
                         '</div>'
            }
        }

        $('.beautiful .swiper-wrapper').html(_html);
        swiper.destroy();
        swiper = new Swiper('.beautiful .swiper-container', {
            // loop: true,
            navigation: {
                nextEl: '.swiper-button-next',
                prevEl: '.swiper-button-prev',
            },
            // 如果需要分页器
            pagination: {
                el: '.swiper-pagination',
                clickable: true,
            },
            initialSlide: 0, //初始化为第一张图
            observer: true, //修改swiper自己或子元素时，自动初始化swiper
            observeParents: true,
        });
        //换form中对应车型
        // var val = ['16','11','15','23','18','19','17','12','14'];
        // console.log(val[idx]);
        // $('#cartype').val(val[idx]);
    });
    
    
}) 